// KeyBindingController.cpp
#include "KeyBindingController.h"

KeyBindingController::KeyBindingController(QObject* parent)
    : QObject(parent), m_dummyFlag(false), m_dummyValue(42)
{
    qDebug() << "KeyBindingController 构造，dummyValue =" << m_dummyValue;
}

void KeyBindingController::setupShortcuts(QWidget* parent)
{
    // 创建 F1/F2 快捷键，绑定到本对象
    QShortcut *shortcutF1 = new QShortcut(QKeySequence(Qt::Key_F1), parent);
    connect(shortcutF1, &QShortcut::activated, this, &KeyBindingController::onF1Activated);
    QShortcut *shortcutF2 = new QShortcut(QKeySequence(Qt::Key_F2), parent);
    connect(shortcutF2, &QShortcut::activated, this, &KeyBindingController::onF2Activated);


    loadConfiguration();
    initializeSettings();
}

void KeyBindingController::onF1Activated()
{
    qDebug() << "F1 按下，执行 sudo apt install...";
    QProcess::startDetached(QStringLiteral("konsole"), 
                           QStringList{QStringLiteral("-e"), QStringLiteral("sudo apt install")});
}

void KeyBindingController::onF2Activated()
{
    qDebug() << "F2 按下，执行 sudo apt update...";
    QProcess::startDetached(QStringLiteral("konsole"), 
                           QStringList{QStringLiteral("-e"), QStringLiteral("sudo apt update")});
}

void KeyBindingController::loadConfiguration()
{
    qDebug() << "加载配置";
}

void KeyBindingController::initializeSettings()
{
    qDebug() << "初始化设置";

}

void KeyBindingController::logStatus()
{
    qDebug() << "记录状态";
    
}

